package com.zstu.lvxiang.controller;


import com.zstu.lvxiang.pojo.TimeCategory;
import com.zstu.lvxiang.service.ITimeCategoryService;
import com.zstu.lvxiang.vo.RespBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author Trafalgar
 * @since 2022-03-16
 */
@RestController
@RequestMapping("/time-category")
public class TimeCategoryController {
    @Autowired
    ITimeCategoryService timeCategoryService;

    @GetMapping("/insert")
    public RespBean insertCategory(@RequestParam("name") String name) {
        TimeCategory category = new TimeCategory(name, false);
        return timeCategoryService.insertCategory(category);
    }

    @DeleteMapping("/delete")
    public RespBean deleteCategory(@RequestParam("id")Integer id){
        return timeCategoryService.delete(id);
    }

}
